package com.siwei.mes.entity.excel;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.siwei.mes.entity.system.Equipment;
import lombok.Data;

import java.util.Date;

/**
 * 导入设备实体
 *
 * @Description: 导入设备实体
 * @Version: 1.0
 * @author: mlchen
 * @date: 2025/7/15 10:25
 */
@Data
public class ImportEquipmentExcel {
    @Excel(name = "设备编号", width = 30)
    private String equipmentNo;

    @Excel(name = "设备类别", replace = {"A_A", "B_B", "C_C"}, addressList = true, width = 30)
    private String equipmentCategory = "";

    @Excel(name = "设备名称", width = 30)
    private String equipmentName;

    @Excel(name = "型号规格", width = 30)
    private String equipmentType;

    @Excel(name = "出厂编号", width = 30)
    private String factoryNumber;

    @Excel(name = "生产厂家", width = 30)
    private String manufacturer;

    @Excel(name = "技术参数", width = 30)
    private String technicalParameter;

    @Excel(name = "价格", width = 30)
    private Double price;

    @Excel(name = "数量", width = 30)
    private String number;

    @Excel(name = "购置日期", exportFormat = "yyyy-MM-dd", importFormat = "yyyy-MM-dd", width = 30)
    private Date buyTime;

    @Excel(name = "出厂时间", exportFormat = "yyyy-MM-dd", importFormat = "yyyy-MM-dd", width = 30)
    private Date factoryTime;

    @Excel(name = "启用时间", exportFormat = "yyyy-MM-dd", importFormat = "yyyy-MM-dd", width = 30)
    private Date enableTime;

    @Excel(name = "分度值", width = 30)
    private String division;

    @Excel(name = "精度等级", width = 30)
    private String accuracyClass;

    @Excel(name = "安放地点", width = 30)
    private String placementLocation;

    @Excel(name = "存放地点", width = 30)
    private String saveAddress;

    @Excel(name = "设备状态", width = 30)
    private String equipmentStatus;

    @Excel(name = "保管人", width = 30)
    private String custodyUserName;

    @Excel(name = "检定周期", width = 30)
    private Integer verificationCycle;

    @Excel(name = "预警设置", width = 30)
    private Integer warningCycle;

    @Excel(name = "备注", width = 30)
    private String notes;

    /**
     * 组装仪器设备信息
     *
     * @param equipmentExcel
     * @return
     */
    public static Equipment payloadEquipmentInfo(ImportEquipmentExcel equipmentExcel) {
        Equipment equipment = new Equipment();
        equipment.setId(null);
        equipment.setEquipmentNo(equipmentExcel.getEquipmentNo());
        equipment.setEquipmentCategory(equipmentExcel.getEquipmentCategory());
        equipment.setEquipmentName(equipmentExcel.getEquipmentName());
        equipment.setEquipmentType(equipmentExcel.getEquipmentType());
        equipment.setFactoryNumber(equipmentExcel.getFactoryNumber());
        equipment.setManufacturer(equipmentExcel.getManufacturer());
        equipment.setSaveAddress(equipmentExcel.getSaveAddress());
        equipment.setTechnicalParameter(equipmentExcel.getTechnicalParameter());
        equipment.setPrice(equipmentExcel.getPrice());
        equipment.setBuyTime(equipmentExcel.getBuyTime());
        equipment.setEnableTime(equipmentExcel.getEnableTime());
        equipment.setEquipmentStatus(equipmentExcel.getEquipmentStatus());
        equipment.setCustodyUserName(equipmentExcel.getCustodyUserName());
        equipment.setWarningCycle(equipmentExcel.getWarningCycle());
        equipment.setVerificationCycle(equipmentExcel.getVerificationCycle());
        equipment.setNumber(equipmentExcel.getNumber());
        equipment.setFactoryTime(equipmentExcel.getFactoryTime());
        equipment.setDivision(equipmentExcel.getDivision());
        equipment.setAccuracyClass(equipmentExcel.getAccuracyClass());
        equipment.setPlacementLocation(equipmentExcel.getPlacementLocation());
        equipment.setNotes(equipmentExcel.getNotes());
        equipment.setCreateTime(new Date());
        equipment.setUpdateTime(new Date());
        equipment.setIsDel(0);
        return equipment;
    }
}
